package de.web;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import de.preisrobot.entity.Anbieter;
import de.preisrobot.persistence.dao.AnbieterDao;


@Controller
@RequestMapping(value="anbieter")
public class AnbieterController
{

	@Resource(name="anbieterDao")
	private AnbieterDao anbieterDao;
	 
   @RequestMapping(value="insert",method=RequestMethod.PUT)
   @ResponseStatus(HttpStatus.CREATED)
   @Transactional(propagation=Propagation.REQUIRES_NEW)
   public void insertNewCoiSeller(@RequestBody Anbieter neuerSeller, HttpServletRequest request, 
            HttpServletResponse response)
   {
      
	     this.anbieterDao.save(neuerSeller);
   }
   
   @RequestMapping(value="getAll",method=RequestMethod.GET)
   public @ResponseBody List<Anbieter> getAllCoiSeller()
   {
	  List<Anbieter> loadAll = this.anbieterDao.loadAll();
      return loadAll;
   }
}
